package com.springmq.mq.juc;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName : Demo9
 * @Author : lby
 * @Date: 2021/2/4 17:26
 * @Description : Strema计算
 */
@Slf4j
public class Demo9 {
    public static void main(String[] args) {
        List<Student> studentList=new ArrayList<>();
        for (int i = 0; i <5 ; i++) {
            Student student = new Student();
            student.setAge(i);
            student.setId(i-1);
            student.setName(String.valueOf(System.currentTimeMillis()));
            studentList.add(student);
        }

        /**
         * 利用stream 计算流对集合进行计算处理
         */
        studentList.stream().filter((Student student1)-> student1.getAge()>1).forEach((Student value)->{
            log.info("数据:{}",value);
        });
        studentList.stream().filter((Student student)-> student.getAge()>0&& student.getId()>0).forEach((Student student)->{
            log.info("数据111:{}",student);
        });
        studentList.stream().map((Student student)-> student.getName().toUpperCase()).forEach(aaa->{
//            System.out.println("数据"+aaa);
            log.info("谁:{}",aaa);
        });
    }


}

@Data
class Student{
    private String name;
    private Integer age;
    private Integer id;
}
